package com.jfinal.demo.service.impl;

import com.jfinal.demo.model.ShoolInfo;
import com.jfinal.demo.model.ShoolInfoDao;
import com.jfinal.demo.service.ShoolInfoService;
import com.jfinal.plugin.activerecord.Page;
import org.springframework.stereotype.Service;

/**
 * 学校service层实现类
 * @author tanghailan
 * @date 2020-12-17 15:19
 */
@Service
public class ShoolInfoServiceImpl implements ShoolInfoService {

    @Override
    public Page<ShoolInfo> getShoolInfoList(int pageNumber,int pageSize) {
        return ShoolInfoDao.getPageShoolInfoList(pageNumber, pageSize);
    }

    @Override
    public Boolean addShoolInfo(String shCity,
                                String shShool) {
        return ShoolInfoDao.addShoolInfo(shCity,shShool);
    }

    @Override
    public int deleteShoolInfo(Long id) {
        return ShoolInfoDao.deleteShoolInfo(id);
    }

    @Override
    public Boolean updateShoolInfo(Integer shId,
                                   String shCity,
                                   String shShool) {
        return ShoolInfoDao.updateShoolInfo(shId,shCity,shShool);
    }

    @Override
    public ShoolInfo getById(Long id) {
        ShoolInfoDao shoolInfoDao = ShoolInfoDao.getById(id);
        ShoolInfo shoolInfo = new ShoolInfo();
        shoolInfo.setSh_shool(shoolInfoDao.getStr("sh_shool"));
        shoolInfo.setSh_city(shoolInfoDao.getStr("sh_city"));
        shoolInfo.setSh_id(shoolInfoDao.getInt("sh_id"));
        return shoolInfo;
    }
}
